import axios from "./request/http";
export const outerBaseUrl = `http://${window.location.hostname}:${window.location.port}`;
// export const outerBaseUrl = `http://192.168.8.196:1257`;

export const outerPost = (method, params) => {
  let data = params;
  if (!params instanceof FormData) {
    data = JSON.stringify(params);
  }
  return axios({
    method: "POST",
    url: `${outerBaseUrl}${method}`,
    data
  }).then(res => {
    return Promise.resolve(res.data);
  });
};

export const getInNeeds = () => {
  return outerPost("/getInNeed", {});
};

export const getPartyList = () => {
  return outerPost("/getPartyList", {});
};

export const getPartyNameList = () => {
  return outerPost("/getPartyNameList", {});
};

export const getPictureList = () => {
  return outerPost("/getPictureList", {});
};

export const getPartyRoster = () => {
  return outerPost("/getPartyRoster", {});
};

export const getPartyLeaders = () => {
  return outerPost("/getPartyLeaders", {});
};

export const getBaseByName = ({ basename }) => {
  return outerPost("/getPartyBases", { basename });
};
export const getPartyRegion = () => {
  return outerPost("/getPartyRegion");
};

export const getFile = path => {
  return `${outerBaseUrl}${path}`;
};
